package com.codefarm.phone.mtsh.doctor.activity;

import android.os.Bundle;

import com.codefarm.phone.mtsh.doctor.R;
import com.codefarm.phone.mtsh.doctor.adapter.MainListAdapter;
import com.fortysevendeg.swipelistview.BaseSwipeListViewListener;
import com.fortysevendeg.swipelistview.SwipeListView;

/**
 * 主界面
 * @author Eriksson
 *
 */
public class MainActivity extends CommonBaseActivity {

	SwipeListView swipeListView;
	MainListAdapter<String> adapter;
	
	@Override
	protected void onCreate(Bundle bundle) {
		super.onCreate(bundle);
		setContentView(R.layout.activity_main);
		initView();
	}
	
	/**
	 * 初始化视图
	 */
	private void initView(){
		swipeListView = (SwipeListView) findViewById(R.id.slv_lv);
		swipeListView.setSwipeOpenOnLongPress(true);
		swipeListView.setAnimationTime(200);
		swipeListView.setItemsCanFocus(true);
		swipeListView.setSwipeListViewListener(new BaseSwipeListViewListener(){
			@Override
			public void onDismiss(int[] reverseSortedPositions) {
				for (int position : reverseSortedPositions) {
	                adapter.remove(position);
	            }
				adapter.notifyDataSetChanged();
			}
		});
		adapter = new MainListAdapter<String>(this,swipeListView);
		adapter.add("测试数据1");
		adapter.add("测试数据2");
		adapter.add("测试数据3");
		adapter.add("测试数据4");
		adapter.add("测试数据5");
		adapter.add("测试数据6");
		adapter.add("测试数据1");
		adapter.add("测试数据2");
		adapter.add("测试数据3");
		adapter.add("测试数据4");
		adapter.add("测试数据5");
		adapter.add("测试数据6");
		adapter.add("测试数据1");
		adapter.add("测试数据2");
		adapter.add("测试数据3");
		adapter.add("测试数据4");
		adapter.add("测试数据5");
		adapter.add("测试数据6");
		adapter.add("测试数据1");
		adapter.add("测试数据2");
		adapter.add("测试数据3");
		adapter.add("测试数据4");
		adapter.add("测试数据5");
		adapter.add("测试数据6");
		swipeListView.setAdapter(adapter);
	}
	
}
